//
//  CashBackApi.swift
//  FeastBooking
//
//  Created by Imon on 2017/11/16.
//  Copyright © 2017年 Imon. All rights reserved.
//

import Foundation
import Moya

enum CashBackApi {
    case getUserCashBack()
    case getOrderCashBack(id: Int)
}

extension CashBackApi: TargetType {
    
    var baseURL: URL {
        return URL(string: serverBasePath)!
    }
    
    var path: String {
        switch self {
        case .getUserCashBack:
            return "/user/cashback"
        case .getOrderCashBack(let id):
            return "/orders/\(id)/cashback"
        }
    }
    
    var method: Moya.Method {
        return .get
    }
    
    var parameters: [String: Any]? {
        return nil
    }
    
    var task: Task {
        return .request
    }
    
    var sampleData: Data {
        return "{\"data\":{\"msg\":\"good\"},\"meta\":{\"status\":200,\"msg\":\"OK\"}}".data(using: String.Encoding.utf8)!
    }
    
    var parameterEncoding: ParameterEncoding {
        return URLEncoding.default
    }
}
